package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CoreRideRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreRideRecord;

@Service("coreRideRecordService")
public class CoreRideRecordServiceImpl implements CoreRideRecordService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCoreRideRecord(CoreRideRecord coreRideRecord) {
		myBatisDAO.insert(coreRideRecord);
		return true;
	}

	@Override
	public boolean updateCoreRideRecord(CoreRideRecord coreRideRecord) {
		myBatisDAO.update(coreRideRecord);
		return true;
	}

	@Override
	public boolean deleteCoreRideRecord(CoreRideRecord coreRideRecord) {
		myBatisDAO.delete(coreRideRecord);
		return true;
	}

	private static final String DELETEBATCH_CORERIDERECORD_BY_IDS="deleteBatchCoreRideRecordByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_CORERIDERECORD_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CoreRideRecord getCoreRideRecord(CoreRideRecord coreRideRecord) {
		return (CoreRideRecord) myBatisDAO.findForObject(coreRideRecord);
	}

	private static final String FIND_CORERIDERECORD_FOR_LISTS="findCoreRideRecordForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreRideRecord> findCoreRideRecordList() {
		return myBatisDAO.findForList(FIND_CORERIDERECORD_FOR_LISTS, null);
	}

	private static final String FIND_CORERIDERECORD_FOR_PAGES="findCoreRideRecordForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreRideRecord> findCoreRideRecordPage(int pageNum, int pageSize, String crrrdTitle, String crrrdUser) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crrrdTitle", crrrdTitle);
		hashMap.put("crrrdUser", crrrdUser);
		return myBatisDAO.findForPage(FIND_CORERIDERECORD_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

	@Override
	public CoreRideRecord getCoreRideRecordByUser(CoreRideRecord coreRideRecord) {
		return (CoreRideRecord) myBatisDAO.findForObject("getCoreRideRecordByUser", coreRideRecord);
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}